package easy.Reader;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.widget.GridView;

public class HomeScreen extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 无title
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);// 禁止竖屏
		setContentView(R.layout.main);

		GridView gridview = (GridView) findViewById(R.id.grid_view);

		ArrayList<Function> meumList = new ArrayList<Function>();
		meumList.add(new FreeNumberFunction(this));
		meumList.add(new ReportFunction(this));
		meumList.add(new FreeNumberFunction(this));
		meumList.add(new ReportFunction(this));
		meumList.add(new FreeNumberFunction(this));
		meumList.add(new ReportFunction(this));
		FunctionsAdapter fa = new FunctionsAdapter(this, meumList);
		gridview.setAdapter(fa);
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = this.getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return true;
	}

	public boolean onOptionsItemSelected(MenuItem mi) {
		int id = mi.getItemId();
		if (id == R.id.about) {
			new AlertDialog.Builder(this).setTitle("About").setMessage(
					"About Message").show();
			this.finish();
		} else {
			this.finish();
		}
		return true;
	}
}